package gameObject.resources3D
{
	import assets.Asset;
	
	import flash.events.Event;
	import flash.net.URLLoader;

	public class BulletResource extends ResourceBase
	{
		private var _bulletURL:String;
		private var _mesh:GameMesh;
		
		private var _type:int;
		private var _speed:Number;
		private var _range:Number;
		
		public function get mesh():GameMesh
		{
			return _mesh;
		}

		public function get type():int
		{
			return _type;
		}
		
		public function get speed():Number
		{
			return _speed;
		}
		
		public function get range():Number
		{
			return _range;
		}
		
		public function BulletResource(ID:int,Type:int,Speed:Number,Range:Number)
		{
			super();
			_id = ID;
			_type = Type;
			_speed = Speed;
			_range = Range;
		}

		override public function load():void
		{
			if(_id>0 && !_mesh )
			{
				_bulletURL = Global.assetPath+"models/bullets/bullet_"+String(_id)+"_mes.xml";
				
				_mesh = new GameMesh(_bulletURL);
				_mesh.addEventListener(Event.COMPLETE,gotMesh);
				_mesh.load();
			}
		}
		
		private function gotMesh(e:Event):void
		{
			addChild(_mesh);
			dispatchEvent(new Event(Event.COMPLETE));
		}
	}
}